package com.example.multitenant.base

import java.io.PrintWriter
import java.io.StringWriter
import java.lang.Exception
import java.util.logging.Logger

/**
 * 2020/8/11
 * By GaoXiang
 * Description:
 */
object Log {

    private fun logger(tag: String): Logger {
        return Logger.getLogger(tag)
    }

    fun i(tag: String, message: String) {
        logger(tag).info(message)
    }

    fun e(tag: String, message: Any) {
        val msg = when (message) {
            is Exception -> {
                val sw = StringWriter()
                message.printStackTrace(PrintWriter(sw))
                sw.toString()
            }
            else -> message.toString()
        }
        logger(tag).severe(msg)
    }
}